/**
 * @param {string} s
 * @return {string}
 */
var reverseOnlyLetters = function (s) {
    const arr = s.split('');
    let i = 0,
        j = s.length - 1;
    let tmp;
    while (i < j) {
        if (!isZimu(arr[i])) {
            i++;
            continue;
        }
        if (!isZimu(arr[j])) {
            j--;
            continue;
        }
        tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
        i++;
        j--;
    }
    return arr.join('');
};

/**
 * @param {char} ch
 * @return {string}
 */
const isZimu = (ch) => {
    if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) return true;
    else return false;
};
